package com.hnust.controller;

import com.hnust.domain.Examinee;
import com.hnust.service.GetStuListService;
import com.hnust.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin("*")
@RestController

@RequestMapping("/check")
public class StuListInfoController {
    @Autowired
    private GetStuListService getStuListService;

    @GetMapping("/getStuList")
    public Result<Map<String, List<Examinee>>> getStuListInfo(
            @RequestParam(value = "testId") String testId,
            @RequestParam(value = "claId") String claId) {
        List<Examinee> stuListInfo = getStuListService.getStudentList(testId,claId);
        Map<String,List<Examinee>> stuList = new HashMap<>();
        stuList.put("student",stuListInfo);
        System.out.println(stuListInfo);
        if(stuListInfo==null){
            return new Result<>(0, "获取失败", null);
        }
        else{
            return new Result<>(1, "获取成功", stuList);
        }
    }
}
